/* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
 
Copyright (C) 2010 by Tomasz Pluskiewicz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */

using System;
using System.Web;

namespace Yama.MVC.Core
{
    ///<summary>
    /// A class pretty much useless on its own, but used by WindsorHttpApplication
    /// to simplify deriving of <see cref="HttpApplication"/>. Basically it makes it 
    /// easier to override any step of the request lifecycle
    ///</summary>
    public abstract class CoreHttpApplication : HttpApplication
    {
        #region System.Web.HttpApplication life cycle

        protected void Application_Start(object sender, EventArgs e)
        {
            ApplicationStart(sender, e);
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            SessionStart(sender, e);
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            ApplicationBeginRequest(sender, e);
        }

        protected void Application_EndRequest(object sender, EventArgs e)
        {
            ApplicationEndRequest(sender, e);
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            ApplicationAuthenticateRequest(sender, e);
        }

        protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
        {
            ApplicationPostAuthenticateRequest(sender, e);
        }

        protected void Application_Error(object sender, EventArgs e)
        {
            ApplicationError(sender, e);
        }

        protected void Session_End(object sender, EventArgs e)
        {
            ApplicationEnd(sender, e);
        }

        protected void Application_End(object sender, EventArgs e)
        {
            ApplicationEnd(sender, e);
        }

        #endregion

        #region Virtual members

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_Start
        ///</summary>
        public virtual void ApplicationStart(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_End
        ///</summary>
        public virtual void ApplicationEnd(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Session_End
        ///</summary>
        public virtual void SessionEnd(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_Error
        ///</summary>
        public virtual void ApplicationError(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_AuthenticateRequest
        ///</summary>
        public virtual void ApplicationAuthenticateRequest(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_PostAuthenticateRequest
        ///</summary>
        public virtual void ApplicationPostAuthenticateRequest(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_BeginRequest
        ///</summary>
        public virtual void ApplicationBeginRequest(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Application_EndRequest
        ///</summary>
        public virtual void ApplicationEndRequest(object sender, EventArgs e) { }

        ///<summary>
        /// Any code, which runs inside <see cref="System.Web.HttpApplication"/>#Session_Start
        ///</summary>
        public virtual void SessionStart(object sender, EventArgs e) { }

        #endregion
    }
}